//
// Description: 125. 验证回文串
// Created by Loading on 2024/11/10.
//

#include <bits/stdc++.h>

using namespace std;

bool isPalindrome(string s) {
    int i = 0, j = s.size() - 1;

    while (i < j) {
        while (i < j && !isalnum(s[i])) {
            ++i;
        }
        while (i < j && !isalnum(s[j])) {
            --j;
        }
        if (i < j && tolower(s[i++]) != tolower(s[j--])) {
            return false;
        }
    }

    return true;
}

int main() {
    string s = "A man, a plan, a canal: Panama";
    bool res = isPalindrome(s);

    cout << res << endl;

    return 0;
}